#
# Cookbook Name:: om
# Recipe:: deployment_accelerator
#
# Copyright 2014, IBM
#
# All rights reserved - Do Not Redistribute
#

wasuser = node[:was][:user]
wasgroup = node[:was][:group]

template "#{node[:om][:installDir]}/properties/deploymentaccelerator.properties" do
  source "deploymentaccelerator.properties.erb"
  owner wasuser
  group wasgroup
  variables(
        :orgcode=> node[:dacconfig][:OrganizationCode],
        :email=> node[:dacconfig][:EMailID],
        :phone=> node[:dacconfig][:Phone],
        :zipcode=> node[:dacconfig][:ZipCode] 
  )
  action :create
end

bash "Install Deployment Accelerator"  do
  user wasuser
  group wasgroup
  cwd "#{node[:om][:installDir]}/bin"
  creates "/tmp/daccinstall.done"
  code <<-EOH
    set -e
    #{node[:om][:installDir]}/bin/sci_ant.sh -f loadDeploymentAccelerator.xml > /tmp/daccInstall.log 2>&1
    touch /tmp/daccinstall.done 
  EOH
end

bash "Rebuild resource.jar"  do
  user wasuser
  group wasgroup
  cwd node[:om][:installDir]
  creates "/tmp/daccinstall.buildresourcejar.done"
  code <<-EOH
    set -e
    #{node[:om][:installDir]}/bin/deployer.sh -t resourcejar
    touch /tmp/daccinstall.buildresourcejar.done 
  EOH
end